package com.teradata.params.core.model;

import com.alibaba.fastjson.JSONObject;
import lombok.*;
import org.junit.Test;

@Data
@NoArgsConstructor
@ToString
public class ColumnType {
    private ParamType paramType;
    private Integer id;
    private String returnParamName;
    private String paramName;
    private String paramDesc;
    private PrimitiveTypeKind orgiType;
    private String lengthPrecision;
    private String note;
    private Boolean isStartDate;
    private Boolean isEndDate;
    private Boolean isProxyCust;
    private Boolean isKey;
    private String checkParamName;
    private String includeValues;
    private String excludeValues;

    @Test
    public void toJson() {
        ColumnType columnType = new ColumnType();
        columnType.setParamType(ParamType.INPARAM);
        columnType.setId(14);
        columnType.setReturnParamName("ZLJYFX");
        columnType.setParamName("CshSttlemDrctn");
        columnType.setParamDesc("现金了结方向描述");
        columnType.setOrgiType(PrimitiveTypeKind.String);
        columnType.setLengthPrecision("10");
        columnType.setIsStartDate(false);
        columnType.setIsEndDate(false);
        columnType.setIsProxyCust(false);
        columnType.setIsKey(false);
        columnType.setCheckParamName("ZLYWLB");
        columnType.setIncludeValues("BT20");
        String jsonString = JSONObject.toJSONString(columnType);
        System.out.println(jsonString);
    }

    @Test
    public void toObject() {
        String jsonStr="{\"checkParamName\":\"ZLYWLB\",\"id\":14,\"includeValues\":\"BT20\",\"isEndDate\":false,\"isKey\":false,\"isProxyCust\":false,\"isStartDate\":false,\"lengthPrecision\":\"10\",\"orgiType\":\"String\",\"paramDesc\":\"现金了结方向描述\",\"paramName\":\"CshSttlemDrctn\",\"paramType\":\"INPARAM\",\"returnParamName\":\"ZLJYFX\"}";
        ColumnType columnType = JSONObject.parseObject(jsonStr, ColumnType.class);
        System.out.println(columnType);
    }
}
